<template>
	<view class="box">
		
		<view @click="toPage('/filePage/pages/programmeDetail/programmeDetail?item='+JSON.stringify(item))"  class="flex bg-white justify-between margin-bottom-sm" v-for='(item,index) in list' :key='index'>
			<view class="bidding-left">
				<view class="nickname">{{item.userName}}</view>
				<view class="phone">电话:{{item.userMobile}}</view>
			</view>
			<view class="price">
				<view>投标价:{{item.competitivePrice}}</view>
				<view class="btn" @click.stop="submit(item.id,item.orderServiceId)">中标</view>
			</view>
		</view>
		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from '@/common/util/BetterPull'
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = 'loading';
					const obj = {
					orderServiceId:this.orderServiceId,
					pageNum: page,
					pageSize: 10,
					}
		
					const [err, res] = await this.$get(this.$api.listDe, obj)
					if (res) {
						var data = res.data.list
						done(data);
						if (data.length < 10) {
							this.loading = 'noMore';
						} else {
							this.loading = 'more';
						}
		
					}
					if (err) {
						done([]);
						this.loading = 'noMore';
					}
				}
			})
		],
		data() {
			return {
              orderServiceId:'',
			  loading: "more",
			  type:'',
			  code:''
			}
		},
		onLoad(option) {
			if(option.id){
				this.orderServiceId = option.id
			}
			if(option.type){
				this.type = option.type
			}
			
		},
	
		methods: {
			
			toPage(url) {
				this.$util.openNewPage(url)

			},
			submit(id,orderServiceId){
				const that =this
				uni.showModal({
				    title: '提示',
				    content: '你确定选择该订单方案吗',
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
							const data={competitiveId:id,orderServiceId}
							that.$get(that.$api.acceptDe,data).then(res=>{
								const [err,rs] = res
								if(rs){
									that.$util.msg(rs.message)
									if(that.type){
										uni.navigateBack({
											delta:1
										})
									}else{
										uni.navigateBack({
											delta:2
										})
									}
								
								}
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style scoped>
	.box {
		padding: 20px;
	}

	.bidding-left {
		padding: 40rpx;
	}

	.nickname {
		margin-bottom: 29rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #181818;
	}

	.phone {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.price {
		display: flex;
		justify-content: center;
		align-items: center;
		padding-right: 42rpx;
	}
	.btn{
		padding: 10rpx;
		background: #ED7200;
		color: #fff;
		border-radius: 10rpx;
		margin-left: 30rpx;
	}
</style>
